package com.itheima.web.service.impl.pms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.service.pms.ProductAttributeCategoryService;
import com.itheima.vo.pms.PmsProductAttribute;
import com.itheima.vo.pms.PmsProductAttributeCategory;
import com.itheima.vo.pms.PmsProductAttributeCategoryDto;
import com.itheima.vo.pms.Product;
import com.itheima.web.mapper.pms.ProductAttributeCategoryMapper;
import com.itheima.web.mapper.pms.ProductMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class ProductAttributeCategoryServiceImpl extends ServiceImpl<ProductAttributeCategoryMapper, PmsProductAttributeCategory> implements ProductAttributeCategoryService {

    @Autowired
    private ProductAttributeCategoryMapper productAttributeCategoryMapper;

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<PmsProductAttributeCategory> pageInfo2(int pageNum, int pageSize) {
        return productAttributeCategoryMapper.pageInfo2(pageNum,pageSize);
    }

    @Override
    public List<PmsProductAttributeCategory> get() {
        return productAttributeCategoryMapper.get();
    }

    @Override
    public List<PmsProductAttribute> getByCAId(Integer id) {
        return productAttributeCategoryMapper.getByCAId(id);
    }

    @Override
    public PmsProductAttributeCategory getOneByName(String name) {
        LambdaQueryWrapper<PmsProductAttributeCategory> lqw=new LambdaQueryWrapper<>();
        lqw.eq(PmsProductAttributeCategory::getName,name);
        PmsProductAttributeCategory pmsProductAttributeCategory = productAttributeCategoryMapper.selectOne(lqw);
        return pmsProductAttributeCategory;
    }

    @Override
    public boolean updateBy(int id, String name) {
        return productAttributeCategoryMapper.updateBy(id,name);
    }

    @Override
    public List<Product> getByIdWithProduct(int id) {
        return productMapper.selectBy(id);
    }
}
